function [img_hat, error] = PCA(img, bases)

        % 求解线性组合系数
        coefficients = bases \ img(:);

        % 重构向量
        img_hat = bases * coefficients;

        % 将重构的向量重新恢复为原始形状
        img_hat = reshape(img_hat, size(img));

        error = norm(img_hat-img, 'fro');
end